package com.health.appoint.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.health.appoint.model.entity.Schedule;
import com.health.appoint.service.ScheduleService;
import com.health.common.exception.BusinessException;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

/**
 * @author zhexueqi
 * @ClassName DoctorAppointController
 * @since 2024/8/27    15:01
 */
@RestController
@RequestMapping("/doctor")
@Tag(name = "医生端预约管理")
public class DoctorAppointController {

    @Resource
    private ScheduleService scheduleService;

    /**
     * 查看医生的排版信息
     */
    @GetMapping("/getSchedule")
    public Page<Schedule> getScheduleForDoctor(@RequestParam("doctorId") @NotNull @Min(1) Long doctorId,
                                       @RequestParam("pageNum") @NotNull Optional<Integer> pageNum ,
                                       @RequestParam("pageSize") @NotNull Optional<Integer> pageSize){
        Integer current = pageNum.orElse(1);
        Integer size = pageSize.orElse(10);
        QueryWrapper<Schedule> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("doctor_id", doctorId);
        LocalDate localDate = LocalDate.now();
        queryWrapper.gt("available_date", localDate);
        return scheduleService.page(new Page<>(current,size),queryWrapper);
    }

    /**
     * 监听链上预约事件
     */

}
